package com.xianbeiying.app.ckgl.fragment;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.InputType;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.xianbeiying.app.ckgl.MyApplication;
import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.adapter.EquipmentZdAdapter;
import com.xianbeiying.app.ckgl.adapter.EquipmentZqAdapter;
import com.xianbeiying.app.ckgl.adapter.PopWindowChoiceWpAdapter;
import com.xianbeiying.app.ckgl.adapter.VarbGridViewAdapter;
import com.xianbeiying.app.ckgl.bean.DevicesBean;
import com.xianbeiying.app.ckgl.bean.EZdBean;
import com.xianbeiying.app.ckgl.bean.EZqBean;
import com.xianbeiying.app.ckgl.bean.FaMenBean;
import com.xianbeiying.app.ckgl.bean.FameZqBean;
import com.xianbeiying.app.ckgl.bean.JsonBean;
import com.xianbeiying.app.ckgl.bean.OpenFmBean;
import com.xianbeiying.app.ckgl.bean.QueZDBean;
import com.xianbeiying.app.ckgl.bean.QueZQBean;
import com.xianbeiying.app.ckgl.bean.SFmTypeBean;
import com.xianbeiying.app.ckgl.bean.UrlBean;
import com.xianbeiying.app.ckgl.bean.ZQFMBean;
import com.xianbeiying.app.ckgl.data.DataUtil;
import com.xianbeiying.app.ckgl.data.EQP;
import com.xianbeiying.app.ckgl.http.HttpCallBackUtil;
import com.xianbeiying.app.ckgl.model.DeleteModel;
import com.xianbeiying.app.ckgl.model.GetModel;
import com.xianbeiying.app.ckgl.model.SetModel;
import com.xianbeiying.app.ckgl.util.DeviceUtil;
import com.xianbeiying.app.ckgl.util.DialogUtile;
import com.xianbeiying.app.ckgl.util.LogUtils;
import com.xianbeiying.app.ckgl.util.RabutUtil;
import com.xianbeiying.app.ckgl.util.StringUtil;
import com.xianbeiying.app.ckgl.util.ToastUtil;
import com.xianbeiying.app.ckgl.widght.AppManager;
import com.xianbeiying.app.ckgl.widght.MyGridView;
import com.xianbeiying.app.ckgl.widght.NoScrollListView;
import com.xianbeiying.app.ckgl.widght.dapengView.DpView;
import com.xianbeiying.app.ckgl.widght.dapengView.Dpdata;
import com.xianbeiying.app.ckgl.widght.datepop.NumberPickerView;
import com.xianbeiying.app.ckgl.widght.datetimepicker.date.DatePickerDialog;
import com.xianbeiying.app.ckgl.widght.popwindow.CenterPopWindow;
import com.xianbeiying.app.ckgl.widght.popwindow.LayoutPopWindow;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

/**
 * 风机
 */
public class VaFragmentss extends BaseFragment implements View.OnClickListener, HttpCallBackUtil, DatePickerDialog.OnDateSetListener, Dpdata {
    private View view;
    private static VaFragmentss vaFragment;

    public static VaFragmentss getInstance() {
        vaFragment = new VaFragmentss();
        return vaFragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.activity_watering_plan, null);
        initHttp();
        init();
        return view;
    }

    //水平滑动的控件,大棚信息的展示
    private LinearLayout ly_wphorizontal;  //水平滑动的布局
    private View va_line; //全部左边的线条
    private TextView tv_va_all;//全部
    private DpView dpView; //大棚显示数据类
    private ScrollView sc_wp;
    private RelativeLayout ly_titile;
    //手动模式
    private ImageView iv_wp_sd;//手动选择
    private LinearLayout ly_wp_manul; //手动布局
    private RadioGroup rd_wp_manul;//手动按钮布局
    private RadioButton wp_close;   //手动关闭按钮
    private RadioButton wp_open;    //手动打开按钮
    private ImageView wp_mchoice_fm;//手动选择阀门(周期也是这个)
    private LayoutPopWindow mmanulPop;//手动或者周期的阀门显示窗口
    private LinearLayout ly_choice_wp_manul;//选中后阀门显示的控件
    private TextView tv_sb_wpmanul;
    private PopWindowChoiceWpAdapter wp_mchoice_fmAdapter;//手动或者周期的阀门数据适配器
    private int mmselectId;    //手动选择的阀门的数组下标
    private MyGridView wp_manulgrid;//手动或者周期的选中阀门的展示控件
    private VarbGridViewAdapter mwpGridViewAdapter; //手动或者周期的选中阀门的展示数据适配器
    private LinearLayout ly_cc_mmanul;//手动或者周期选择阀门的布局
    private TextView wp_mmanul_fm;//设备名
    //周期模式
    private ImageView iv_wp_zq;//周期选择
    private LinearLayout ly_wp_zq;//周期布局
    private TextView tv_wpzq_qd;//周期参与计划
    private RelativeLayout rd_wp_zqmanul;//周期按钮布局
    private RadioButton wp_zqopen; //周期打开按钮
    private RadioButton wp_zqclose;//周期关闭按钮
    private TextView tv_wp_manul_end; //周期时间结束
    private TextView tv_wp_manul_start; //周期时间开始
    private EditText et_wp_manul_sc, et_wp_manul_zq;//时长，周期
    private CenterPopWindow manulstarttime, manulendtime;//开始结束时间的窗口
    private NoScrollListView wp_manul_list;//周期计划的列表
    private LinearLayout ly_cy_plant;//参与计划布局
    private EquipmentZqAdapter equipMentZqAdapter;
    private TextView tv_wpzq_delete;//删除周期计划
    //自动模式
    private ImageView iv_wp_zd;//自动选择
    private LinearLayout ly_choice_wp_auto;//显示选择阀门的布局
    private LinearLayout ly_wp_auto; //自动布局
    private EditText et_wpauto_sc, et_wpauto_sd, et_wpauto_wd;//湿度,时长
    private TextView tv_wpzd_qd;//自动参与计划
    private RelativeLayout rd_wp_auto; //自动按钮布局
    private RadioButton wp_start; //自动打开按钮
    private RadioButton wp_stop;//自动关闭按钮
    private ImageView wp_aauto_fm;//自动选择阀门
    private LayoutPopWindow aautoPop;//自动的阀门显示窗口
    private PopWindowChoiceWpAdapter wp_achoice_Adapter;//自动的阀门数据适配器
    private MyGridView wp_autogrid;//自动的选中阀门的展示控件
    private VarbGridViewAdapter avwpGridViewAdapter;//自动的选中阀门的展示数据适配器
    private LinearLayout ly_zdplant;//自动的参与计划布局
    private NoScrollListView wp_auto_list;//自动计划的列表
    private LinearLayout ly_auto_middle;//自动计划的内容
    private TextView tv_wpzd_delete;//自动删除
    private TextView tv_sb_wpauto;
    private EquipmentZdAdapter equipMentZdAdapter;
    private TextView wp_aautochoice_fm;
    private ImageView iv_x;//下
    private TextView tv_x, tv_xd;
    private ImageView iv_s;//上
    private TextView tv_s, tv_sd;
    //网络请求类
    private GetModel getModel;
    private SetModel setModel;
    private DeleteModel deleteModel;

    /**
     * 网络请求初始化
     **/
    private void initHttp() {
        getModel = new GetModel(getActivity());
        setModel = new SetModel(getActivity());
        deleteModel = new DeleteModel(getActivity());
        getModel.addResponseListener(this);
        setModel.addResponseListener(this);
        deleteModel.addResponseListener(this);
    }

    private void init() {
        //水平滑动的控件,大棚信息的展示
        ly_wphorizontal = (LinearLayout) view.findViewById(R.id.ly_wphorizontal);
        va_line = (View) view.findViewById(R.id.va_line);
        tv_va_all = (TextView) view.findViewById(R.id.tv_va_all);
        //标题
        ly_titile = (RelativeLayout) view.findViewById(R.id.ly_titile);
        ly_titile.setVisibility(View.GONE);

        sc_wp = (ScrollView) view.findViewById(R.id.sc_wp);

        initShouDong();
        initZhongQi();
        initZiDong();
        initData();
        initEvent();
    }

    /**
     * 自动模式
     */
    private void initZiDong() {
        iv_wp_zd = (ImageView) view.findViewById(R.id.iv_wp_zd);
        ly_wp_auto = (LinearLayout) view.findViewById(R.id.ly_wp_auto);
        tv_wpzd_qd = (TextView) view.findViewById(R.id.tv_wpzd_qd);
        tv_sb_wpauto = (TextView) view.findViewById(R.id.tv_sb_wpauto);
        rd_wp_auto = (RelativeLayout) view.findViewById(R.id.rd_wp_auto);
        wp_start = (RadioButton) view.findViewById(R.id.wp_start);
        wp_stop = (RadioButton) view.findViewById(R.id.wp_stop);
        wp_aauto_fm = (ImageView) view.findViewById(R.id.wp_aauto_fm);
        wp_autogrid = (MyGridView) view.findViewById(R.id.wp_autogrid);
        ly_zdplant = (LinearLayout) view.findViewById(R.id.ly_zdplant);
        wp_auto_list = (NoScrollListView) view.findViewById(R.id.wp_auto_list);
        ly_auto_middle = (LinearLayout) view.findViewById(R.id.ly_auto_middle);
        et_wpauto_sc = (EditText) view.findViewById(R.id.et_wpauto_sc);
        et_wpauto_sd = (EditText) view.findViewById(R.id.et_wpauto_sd);
        int  inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL;
        et_wpauto_sd.setInputType(inputType);
        et_wpauto_wd = (EditText) view.findViewById(R.id.et_wpauto_wd);
        ly_choice_wp_auto = (LinearLayout) view.findViewById(R.id.ly_choice_wp_auto);
        tv_wpzd_delete = (TextView) view.findViewById(R.id.tv_wpzd_delete);
        wp_aautochoice_fm = (TextView) view.findViewById(R.id.wp_aautochoice_fm);
        iv_x = (ImageView) view.findViewById(R.id.iv_x);
        tv_x = (TextView) view.findViewById(R.id.tv_x);
        tv_xd = (TextView) view.findViewById(R.id.tv_xd);
        iv_s = (ImageView) view.findViewById(R.id.iv_s);
        tv_s = (TextView) view.findViewById(R.id.tv_s);
        tv_sd = (TextView) view.findViewById(R.id.tv_sd);
        wp_aautochoice_fm.setText("选择风机");
        iv_x.setImageResource(R.mipmap.wd);
        tv_x.setText("空气温度下限");
        tv_xd.setText("℃");
        iv_s.setImageResource(R.mipmap.wd);
        tv_s.setText("空气温度上限");
        tv_sd.setText("℃");
    }

    /**
     * 周期模式
     */
    private void initZhongQi() {
        iv_wp_zq = (ImageView) view.findViewById(R.id.iv_wp_zq);
        ly_wp_zq = (LinearLayout) view.findViewById(R.id.ly_wp_zq);
        ly_cy_plant = (LinearLayout) view.findViewById(R.id.ly_cy_plant);
        tv_wpzq_qd = (TextView) view.findViewById(R.id.tv_wpzq_qd);
        rd_wp_zqmanul = (RelativeLayout) view.findViewById(R.id.rd_wp_zqmanul);
        wp_zqopen = (RadioButton) view.findViewById(R.id.wp_zqopen);
        wp_zqclose = (RadioButton) view.findViewById(R.id.wp_zqclose);
        et_wp_manul_sc = (EditText) view.findViewById(R.id.et_wp_manul_sc);
        et_wp_manul_zq = (EditText) view.findViewById(R.id.et_wp_manul_zq);
        tv_wp_manul_start = (TextView) view.findViewById(R.id.tv_wp_manul_start);
        tv_wp_manul_end = (TextView) view.findViewById(R.id.tv_wp_manul_end);
        wp_manul_list = (NoScrollListView) view.findViewById(R.id.wp_manul_list);
        tv_wpzq_delete = (TextView) view.findViewById(R.id.tv_wpzq_delete);
    }

    /**
     * 手动模式
     */
    private void initShouDong() {
        iv_wp_sd = (ImageView) view.findViewById(R.id.iv_wp_sd);
        ly_wp_manul = (LinearLayout) view.findViewById(R.id.ly_wp_manul);
        rd_wp_manul = (RadioGroup) view.findViewById(R.id.rd_wp_manul);
        wp_open = (RadioButton) view.findViewById(R.id.wp_open);
        wp_close = (RadioButton) view.findViewById(R.id.wp_close);
        wp_mchoice_fm = (ImageView) view.findViewById(R.id.wp_mchoice_fm);
        tv_sb_wpmanul = (TextView) view.findViewById(R.id.tv_sb_wpmanul);
        wp_manulgrid = (MyGridView) view.findViewById(R.id.wp_manulgrid);
        ly_cc_mmanul = (LinearLayout) view.findViewById(R.id.ly_cc_mmanul);
        wp_mmanul_fm = (TextView) view.findViewById(R.id.wp_mmanul_fm);
        ly_choice_wp_manul = (LinearLayout) view.findViewById(R.id.ly_choice_wp_manul);
        //模式设置手动
        iv_wp_sd.setSelected(true);
        wp_close.setChecked(true);
        wp_mmanul_fm.setText("选择风机");
    }

    /**
     * 控件数据
     */
    private void initData() {

      if (MyApplication.devicesBean != null) {
            devicesBean = MyApplication.devicesBean;
            getData(devicesBean.getGREENHOUSE(), devicesBean.getGREENHOUSE().size(), 0);
            //获取所有的设置信息
            getModel.QUWEYDEVSDetauls("GET_ALLDEVICES_STATUS", devicesBean.getGREENHOUSE().get(0).getGreenhouseId(), true);
        } else {
            //获取大棚数据
            getModel.QUWEYDEVS(true);
        }
    }

    /**
     * 控件监听事件设置
     */
    private void initEvent() {
        tv_va_all.setOnClickListener(this);
        //手动模式
        iv_wp_sd.setOnClickListener(this);
        wp_mchoice_fm.setOnClickListener(this);
        wp_open.setOnClickListener(this);
        wp_close.setOnClickListener(this);
        //周期模式
        iv_wp_zq.setOnClickListener(this);
        tv_wp_manul_start.setOnClickListener(this);
        tv_wp_manul_end.setOnClickListener(this);
        tv_wpzq_qd.setOnClickListener(this);
        wp_zqopen.setOnClickListener(this);
        wp_zqclose.setOnClickListener(this);
        tv_wpzq_delete.setOnClickListener(this);
        //自动模式
        iv_wp_zd.setOnClickListener(this);
        wp_aauto_fm.setOnClickListener(this);
        tv_wpzd_qd.setOnClickListener(this);
        wp_start.setOnClickListener(this);
        wp_stop.setOnClickListener(this);
        tv_wpzd_delete.setOnClickListener(this);

    }

    /**
     * 大棚的数据
     */
    private void getData(List<DevicesBean.GREENHOUSEBean> DEVICES, int size, final int id) {
        dpView = new DpView(DEVICES, size, id, ly_wphorizontal, getActivity());
        dpView.setDpdata();
        dpView.addResponseListener(this);
    }

    //选择大棚的数组下标
    private int faId;

    /**
     * 大棚数据
     */
    private boolean isselectDp;
    @Override
    public void onDpdata(int sid, boolean isChoice) {
        isselectDp=isChoice;
        if (isChoice) {
            faId = sid;
            ly_choice_wp_manul.setVisibility(View.GONE);
            //获取所有的设置信息
//            if(selectModelId==0){
                getModel.QUWEYDEVSDetauls("GET_ALLDEVICES_STATUS", devicesBean.getGREENHOUSE().get(sid).getGreenhouseId(), true);
//            }
        }
    }

    private DevicesBean devicesBean;//大棚返回的数据
    private FaMenBean faMenBean;//获取所有设备的信息
    private ArrayList<FaMenBean.VBean.STATUSBean> listFa;//获取阀门设备信息
    private String[] fmType;//阀门状态信息
    private OpenFmBean openFmBean;//手动设置阀门后返回的参数信息
    private QueZQBean queZQBean;//查询周期计划获取的参数信息
    private List<EZqBean> eZqBean;//周期计划的遍历后的数据
    private ZQFMBean zqfmBean;//设置周期计划返回的参数信息
    private List<EZdBean> eZdBean;//自动计划的遍历后的数据
    private QueZDBean queZDBean;//查询自动计划获取的参数信息
    private boolean isZqplant=true;
    private boolean isZdplant=true;
    /**
     * 网络数据返回值
     */
    @Override
    public void onCallBackData(String url, Object content) {
        //大棚数据
        if (url.equals(UrlBean.QUWEYDEVS)) {
            if (content != null) {
                devicesBean = JSON.parseObject(new String((byte[]) content), DevicesBean.class);
                MyApplication.devicesBean = devicesBean;
                getData(devicesBean.getGREENHOUSE(), devicesBean.getGREENHOUSE().size(), 0);
                //获取所有的设置信息
                getModel.QUWEYDEVSDetauls("GET_ALLDEVICES_STATUS", devicesBean.getGREENHOUSE().get(0).getGreenhouseId(), false);
            }
        }
        //所有设备的信息
        if (url.equals("大棚信息")) {
            if (content != null) {
                faMenBean = JSON.parseObject(new String((byte[]) content), FaMenBean.class);
                if (faMenBean.isR()) {
                    listFa = DataUtil.getSeBei(faMenBean, EQP.EQP_TYPE_FAN);
                    fmType = DataUtil.getFmOcc(listFa);
                }
                if(isselectDp){
                    if (selectModelId == 1) {
                        //查询周期计划
                        if (devicesBean != null) {
                            if (eZqBean != null) eZqBean.clear();
                            setZq();
                            getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                        }
                    }
                    if (selectModelId == 2) {
                        //查询自动计划
                        if (devicesBean != null) {
                            setZd();
                            if (eZdBean != null) eZdBean.clear();
                            getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                        }
                    }
                }
            }
        }
        if (url.equals("设置风机")) {
            if (content != null) {
                openFmBean = JSON.parseObject(new String((byte[]) content), OpenFmBean.class);
                if (openFmBean.isR()) {
                    //重新获取设备信息
                    getModel.QUWEYDEVSDetauls("GET_ALLDEVICES_STATUS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), false);
                    ToastUtil.showInfo(getActivity(), "操作成功");
                } else {
                    ToastUtil.showInfo(getActivity(), openFmBean.getERR_MSG());
                }
            }
        }
        if (url.equals("查询周期")) {
            if (content != null) {
                queZQBean = JSON.parseObject(new String((byte[]) content), QueZQBean.class);
                if (queZQBean.isR()) {
                    if (queZQBean.getV().getPLANS().size() != 0) {
                        isZqPlant = true;
                        ly_cc_mmanul.setVisibility(View.GONE);
                        tv_wpzq_delete.setVisibility(View.VISIBLE);
                        ly_wp_zq.setVisibility(View.GONE);
                        ly_cy_plant.setVisibility(View.GONE);
                        rd_wp_zqmanul.setVisibility(View.VISIBLE);
                        eZqBean = DeviceUtil.getBeanZqBean(queZQBean, listFa);
                        equipMentZqAdapter = new EquipmentZqAdapter(getActivity(), eZqBean);
                        equipMentZqAdapter.setHandler(handler);
                        wp_manul_list.setAdapter(equipMentZqAdapter);
                        sc_wp.smoothScrollBy(0, 0);
                        EquipmentZqAdapter.isChange = false;
                        EquipmentZqAdapter.isStartZq = true;
                        LogUtils.e("返回的状态:", queZQBean.getV().getPLANS().get(0).getSTATUS() + "=====");
                        wp_zqclose.setChecked(false);
                        wp_zqopen.setChecked(true);
                        if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                            wp_zqclose.setChecked(true);
                        }
                        if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 1) {
                            wp_zqopen.setChecked(true);
                        }
                        if(queZQBean.getV().getPLANS().get(0).getSTATUS()==2){
                            wp_zqopen.setChecked(false);
                            if(isZqplant){
                                // 2正在停用 3秒后在进行查询
//                                DialogUtile.showLoadingss(getActivity(), "正在停止...");
//                                new Handler().postDelayed(new Runnable() {
//                                    @Override
//                                    public void run() {
                                        //3秒后进行查询
                                        isZqplant=false;
                                        DialogUtile.closeDialog();
                                        getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 0, true);

//                                    }
//                                },1000);
                            }
                        }
                        if (queZQBean.getV().getPLANS().get(0).getSTATUS() == -1) {
                            wp_zqopen.setChecked(false);
                        }
                    } else {
                        isZqPlant = false;
                        wp_manul_list.setAdapter(null);
                        mplantId = 0;
                        tv_wpzq_qd.setText("参与计划");
                    }

                }
            }
        }
        if (url.equals("设置阀门周期")) {
            if (content != null) {
                zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
                if (zqfmBean.isR()) {
                    if (zqfmBean.getERR_MSG().contains("下发计划到设备失败")) {
                        ToastUtil.showInfo(getActivity(), zqfmBean.getERR_MSG());
                        if (devicesBean != null) {
                            getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                            return;
                        }
                    }
                    //启动计划
                    setModel.START_CYCLEPLANS("START_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);

                } else {
                    ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
//                    if (devicesBean != null) {
//                        getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
//                    }
                }
            }
        }

        if (url.equals("启动周期性阀门")) {
            if (content != null) {
                zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
                if (zqfmBean.isR()) {
                    ToastUtil.showInfo(getActivity(), "操作成功");
                } else {
                    ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
                }
                if (devicesBean != null) {
                    getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                }

            }
        }

        if (url.equals("停止周期性阀门")) {
            if (content != null) {
                zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
                if (zqfmBean.isR()) {
                    if (isDeleteZqPlant) {
                        //直接删除
                        deleteModel.DeleteQUERY_CYCLEPLANS("DELETE_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                    } else {
                        wp_zqclose.setChecked(true);
                        wp_zqopen.setChecked(false);
                        ToastUtil.showInfo(getActivity(), "操作成功");
                        if (devicesBean != null) {
                            getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                        }
                    }

                } else {
                    wp_zqclose.setChecked(false);
                    wp_zqopen.setChecked(true);
                    ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
                    if (devicesBean != null) {
                        getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                    }
                }

            }
        }
        if (url.equals("删除周期")) {
            zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
            if (zqfmBean.isR()) {
                if (isDownZqPlant) {
                    setModel.SET_CYCLEPLANSS("SET_CYCLEPLANS", 2, EQP.EQP_TYPE_FAN, eZqBean, true);
                } else {
                    ToastUtil.showInfo(getActivity(), "操作成功");
                    isDeleteZqPlant = false;
                    zQdeletepop.dismiss();
                    eZqBean.clear();
                    equipMentZqAdapter.notifyDataSetChanged();
                    setZq();
//                    if (devicesBean != null) {
//                        getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 4, true);
//                    }
                }

            } else {
                ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
            }

        }
        if (url.equals("查询智能")){
            if (content != null){
                queZDBean = JSON.parseObject(new String((byte[]) content), QueZDBean.class);
                if (queZDBean.isR()){
                    if (queZDBean.getV().getPLANS().size() != 0) {
                        isZdPlant = true;
                        tv_wpzd_delete.setVisibility(View.VISIBLE);
                        ly_wp_auto.setVisibility(View.VISIBLE);
                        ly_zdplant.setVisibility(View.GONE);
                        ly_auto_middle.setVisibility(View.GONE);
                        rd_wp_auto.setVisibility(View.VISIBLE);
                        eZdBean = DeviceUtil.getBeanZdBean(queZDBean, listFa);
                        equipMentZdAdapter = new EquipmentZdAdapter(getActivity(), eZdBean, "风机");
                        wp_auto_list.setAdapter(equipMentZdAdapter);
                        sc_wp.smoothScrollBy(0, 0);
                        wp_stop.setChecked(false);
                        wp_start.setChecked(true);
                        EquipmentZdAdapter.isChange = false;
                        EquipmentZdAdapter.isStartZd = true;
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                            wp_stop.setChecked(true);
                        }
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 1) {
                            wp_start.setChecked(true);
                        }
                        if(queZDBean.getV().getPLANS().get(0).getSTATUS()==2){
                            wp_start.setChecked(false);
                            if(isZdplant){
                                // 2正在停用 3秒后在进行查询
//                                DialogUtile.showLoadingss(getActivity(), "正在停止...");
//                                new Handler().postDelayed(new Runnable() {
//                                    @Override
//                                    public void run() {
                                        //3秒后进行查询
                                        isZdplant=false;
                                        DialogUtile.closeDialog();
                                        getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);

//                                    }
//                                },1000);
                            }
                        }
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == -1) {
                            wp_start.setChecked(false);
                        }
                    } else {
                        isZdPlant = false;
                        wp_auto_list.setAdapter(null);
                        aplantId = 0;
                        tv_wpzd_qd.setText("参与计划");
                    }

                }
            }
        }

        if (url.equals("设置智能计划")) {
            if (content != null) {
                zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
                if (zqfmBean.isR()) {
                    if (zqfmBean.getERR_MSG().contains("下发计划到设备失败")) {
                        ToastUtil.showInfo(getActivity(), zqfmBean.getERR_MSG());
                        //查询自动计划
                        if (devicesBean != null) {
                            getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                            return;
                        }
                    }
                    //启动计划
                    setModel.START_TRIGGERPLANS("START_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);

                } else {
                    ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
//                    if (devicesBean != null) {
//                        getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
//                    }
                }
            }
        }

        if (url.equals("启动智能计划")) {
            if (content != null) {
                zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
                if (zqfmBean.isR()) {
                    ToastUtil.showInfo(getActivity(), "操作成功");

                } else {
                    ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
                }
                if (devicesBean != null) {
                    getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                }
            }
        }
        if (url.equals("停止智能计划")) {
            if (content != null) {
                zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
                if (zqfmBean.isR()) {
                    if (isDeleteZdPlant) {
                        deleteModel.DeleteQUERY_TRIGGERPLANS("DELETE_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                    } else {
                        isDeleteZdPlant = false;
                        wp_stop.setChecked(false);
                        wp_start.setChecked(true);
                        ToastUtil.showInfo(getActivity(), "操作成功");
                        if (devicesBean != null) {
                            getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                        }
                    }

                } else {
                    wp_stop.setChecked(true);
                    wp_start.setChecked(false);
                    ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
                    if (devicesBean != null) {
                        getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                    }
                }

            }
        }

        if (url.equals("删除自动")) {
            zqfmBean = JSON.parseObject(new String((byte[]) content), ZQFMBean.class);
            if (zqfmBean.isR()) {
                if (isDownZdPlant) {
                    setModel.SET_TRIGGERPLANSS("SET_TRIGGERPLANS", 3, EQP.EQP_TYPE_FAN, eZdBean, true);
                } else {
                    ToastUtil.showInfo(getActivity(), "操作成功");
                    zDdeletepop.dismiss();
                    eZdBean.clear();
                    equipMentZdAdapter.notifyDataSetChanged();
                    setZd();
//                    if (devicesBean != null){
//                        getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(),3, true);
//                    }
                    isDeleteZdPlant = false;
                    DialogUtile.closeDialog();
                }
            } else {
                ToastUtil.showInfo(getActivity(), "操作失败" + zqfmBean.getERR_MSG());
            }
        }
    }

    private int itemSelectId;//子控件中时间的标志
    private TextView tv_ezq_start, tv_ezq_end;//子控件中的开始时候,结束时间
    private int itemId;//子控件中的id;
    /**
     * 子控件的监听
     */
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                //周期开始时间
                case R.id.tv_ezq_start:
                    itemSelectId = 1;
                    itemId = msg.arg1;
                    View view= (View)msg.obj;
                    tv_ezq_start = (TextView)view.findViewById(R.id.tv_ezq_start);
                    tv_ezq_end=(TextView)view.findViewById(R.id.tv_ezq_end);
                    showStartTimePopWindow();
                    break;
                //周期结束时间
                case R.id.tv_ezq_end:
                    itemSelectId = 2;
                    itemId = msg.arg1;
                    View views= (View)msg.obj;
                    tv_ezq_start = (TextView)views.findViewById(R.id.tv_ezq_start);
                    tv_ezq_end=(TextView)views.findViewById(R.id.tv_ezq_end);
                    showEndTimePop();
                    break;
            }
        }
    };
    private ArrayList<String> vaManulList;//手动或者周期选中的阀门名称
    private ArrayList<String> vaAutoList;//自动选择的阀门名称
    private int selectModelId;//选中的是哪种模式
    private SFmTypeBean sFmTypeBean;//手动阀门设置的参数类
    private String starttime, enttime, etsc, etzq;//开始，结束时间,时长，周期
    private ArrayList<Boolean> entbtn;    //设置标识,用于判断周期阀门按钮不可选
    private ArrayList<Boolean> zdtbtn;   //设置标识,用于判断自动阀门按钮不可选
    private ArrayList<FameZqBean> arrayList = new ArrayList<>();//周期阀门设置的参数
    private ArrayList<FameZqBean> autoarrayList = new ArrayList<>();  //自动阀门设置的参数
    private int mplantId;//周期计划的编号
    private boolean isZqPlant;//是否存在周期计划
    private boolean isDeleteZqPlant;//是否删除周期计划;
    private boolean isDownZqPlant;//是否下发周期计划;
    private int endprior;//开始设置前一个结束时间戳;
    private boolean iszqplantId;//判断周期计划是否是同一组的
    private boolean iszdplantId;//判断自动计划是否是同一组的
    private int aplantId;//自动计划的编号
    private boolean isZdPlant;//是否存在自动计划
    private boolean isDeleteZdPlant;//是否删除自动计划;
    private boolean isDownZdPlant;//是否下发自动计划;
    private CenterPopWindow zDdeletepop;//自动删除窗口提示
    private CenterPopWindow zQdeletepop;//周期删除窗口提示
    private CenterPopWindow selectTime;
    private NumberPickerView mPickerViewH;
    private NumberPickerView mPickerViewM;
    /**
     * 控件监听
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            //全部
            case R.id.tv_va_all:
                va_line.setVisibility(View.GONE);
                tv_va_all.setVisibility(View.GONE);
                break;
            //手动模式
            case R.id.iv_wp_sd:
                showDefault();
                selectModelId = 0;
                getModel.QUWEYDEVSDetauls("GET_ALLDEVICES_STATUS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), true);
                ly_cc_mmanul.setVisibility(View.VISIBLE);
                ly_wp_manul.setVisibility(View.VISIBLE);
                rd_wp_manul.setVisibility(View.VISIBLE);
                ly_cy_plant.setVisibility(View.VISIBLE);
                iv_wp_sd.setSelected(true);
                wp_close.setChecked(true);
                break;
            //周期模式
            case R.id.iv_wp_zq:
                setZq();
                if (devicesBean != null) {
                    getModel.QUERY_CYCLEPLANS("QUERY_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                }
                break;
            //自动模式
            case R.id.iv_wp_zd:
                setZd();
                if (devicesBean != null) {
                    getModel.QUERY_TRIGGERPLANS("QUERY_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                }
                break;
            //自动或者周期模式下的阀门选择
            case R.id.wp_mchoice_fm:
                showSorZpopWindow();
                break;
            //自动模式下的阀门选择
            case R.id.wp_aauto_fm:
                showZdpopWindow();
                break;
            //手动模式或者周期模式或者自动选择阀门的确定
            case R.id.tv_qchoicewp:
                //手动
                if (mmanulPop != null && mmanulPop.isShowing()) {
                    if (wp_mchoice_fmAdapter != null && wp_mchoice_fmAdapter.getIsBoolean() != null) {
                        if (selectModelId == 0) {
                            if (fmType != null && fmType.length != 0)
                                RabutUtil.setRabutChoice(fmType, wp_open, wp_close, mmselectId);
                        }
                        if (selectModelId == 1) {
                            iszqplantId = false;
                        }
                        if (listFa != null && listFa.size() != 0)
                            vaManulList = DataUtil.choiceSeBieList(wp_mchoice_fmAdapter, listFa);
                        ly_choice_wp_manul.setVisibility(View.VISIBLE);
                        if (vaManulList != null) {
                            mwpGridViewAdapter = new VarbGridViewAdapter(getActivity(), vaManulList, "号风机");
                            wp_manulgrid.setAdapter(mwpGridViewAdapter);
                        }
                    }
                    mmanulPop.dismiss();
                }
                //自动
                if (aautoPop != null && aautoPop.isShowing()) {
                    if (wp_achoice_Adapter != null && wp_achoice_Adapter.getIsBoolean() != null) {
                        iszdplantId = false;
                        if (listFa != null)
                            vaAutoList = DataUtil.choiceSeBieList(wp_achoice_Adapter, listFa);
                        ly_choice_wp_auto.setVisibility(View.VISIBLE);
                        if (vaAutoList != null) {
                            avwpGridViewAdapter = new VarbGridViewAdapter(getActivity(), vaAutoList, "号风机");
                            wp_autogrid.setAdapter(avwpGridViewAdapter);
                        }
                    }
                    aautoPop.dismiss();
                }
                break;
            //周期开始时间
            case R.id.tv_wp_manul_start:
                itemSelectId = 0;
                showStartTimePopWindow();
                break;
            //周期结束时间
            case R.id.tv_wp_manul_end:
                itemSelectId = 0;
                showEndTimePop();
                break;
            //时间的确定
            case R.id.tv_pop_qtime:
                String yearss = et_year.getText().toString();
                String months = et_month.getText().toString();
                String days = et_day.getText().toString();
                String hhs = et_hh.getText().toString();
                String mms = et_mm.getText().toString();
                if (DeviceUtil.isInputTimeNull(getActivity(), yearss, months, days, hhs, mms)) {
                    if (manulstarttime != null && manulstarttime.isShowing()) {
                        String start = yearss + "-" + months + "-" + days + "  " + hhs + ":" + mms;
                        int startTime = com.xianbeiying.app.ckgl.util.DataUtil.getTime(start, "yyyy-MM-dd HH:mm");
                        int downTime = com.xianbeiying.app.ckgl.util.DataUtil.getTime(com.xianbeiying.app.ckgl.util.DataUtil.dateHTime(), "yyyy-MM-dd HH:mm");
                        if (startTime < downTime) {
                            ToastUtil.showInfo(getActivity(), "选择时间不能小于当前时间");
                            return;
                        }
                        if (itemSelectId == 0) {
                            if (endprior == 0) {
                                manulstarttime.dismiss();
                                tv_wp_manul_start.setText(start);
                            } else {
                                tv_wp_manul_start.setText(start);
//                                int lasttime = com.xianbeiying.app.zngg.util.DataUtil.getTime(tv_wp_manul_start.getText().toString().trim(), "yyyy-MM-dd HH:mm");
//                                if (lasttime <= endprior && lasttime != 0) {
//                                    ToastUtil.showInfo(getActivity(), "您选择的时间，已经出现在分组里面");
//                                    return;
//                                } else {
                                manulstarttime.dismiss();
//                                }
                            }

                        }
                        if (itemSelectId == 1) {
                            manulstarttime.dismiss();
                            tv_ezq_start.setText(start);
                            eZqBean = DeviceUtil.updateZqBean(eZqBean, tv_ezq_start.getText().toString(), "", 0, 0, itemId);
                            EquipmentZqAdapter.isChange = true;
                            equipMentZqAdapter.notifyDataSetChanged();
                        }
                    }
                    if (manulendtime != null && manulendtime.isShowing()) {
                        String end = yearss + "-" + months + "-" + days + "  " + hhs + ":" + mms;
                        int endTime = com.xianbeiying.app.ckgl.util.DataUtil.getTime(end, "yyyy-MM-dd HH:mm");
                        int downTime = com.xianbeiying.app.ckgl.util.DataUtil.getTime(com.xianbeiying.app.ckgl.util.DataUtil.dateHTime(), "yyyy-MM-dd HH:mm");
                        if (endTime < downTime) {
                            ToastUtil.showInfo(getActivity(), "选择时间不能小于当前时间");
                            return;
                        }
                        if (itemSelectId == 0) {
                            String startTime = tv_wp_manul_start.getText().toString().trim();
                            if (startTime.isEmpty()) {
                                ToastUtil.showInfo(getActivity(), "请先选择开始时间");
                                manulendtime.dismiss();
                                return;
                            }
                            tv_wp_manul_end.setText(end);
                            String sc = com.xianbeiying.app.ckgl.util.DataUtil.getSLong(tv_wp_manul_start.getText().toString(), tv_wp_manul_end.getText().toString());
                            if (sc != null && sc.contains("-") || sc.equals("0")) {
                                ToastUtil.showInfo(getActivity(), "结束时间不能小于开始时间");
                                return;
                            } else {
                                manulendtime.dismiss();
//                                et_wp_manul_sc.setText(sc);
                            }
                        }
                        if (itemSelectId == 2) {
                            tv_ezq_end.setText(end);
                            String sc = com.xianbeiying.app.ckgl.util.DataUtil.getSLong(tv_ezq_start.getText().toString(), tv_ezq_end.getText().toString());
                            if (sc != null && sc.contains("-") || sc.equals("0")) {
                                ToastUtil.showInfo(getActivity(), "结束时间不能小于开始时间");
                                return;
                            } else {
                                manulendtime.dismiss();
                                EquipmentZqAdapter.isChange = true;
                                eZqBean = DeviceUtil.updateZqBean(eZqBean, tv_ezq_start.getText().toString(), tv_ezq_end.getText().toString(), 0, 0, itemId);
                                equipMentZqAdapter.notifyDataSetChanged();
                            }
                        }
                    }
                }
                break;
            //年
            //关闭时间窗口
            case R.id.ly_pop_chocice_time:
                if (manulstarttime != null && manulstarttime.isShowing()) {
                    manulstarttime.dismiss();
                }
                if (manulendtime != null && manulendtime.isShowing()) {
                    manulendtime.dismiss();
                }
                break;
            //周期参与计划
            case R.id.tv_wpzq_qd:
                if (wp_mchoice_fmAdapter != null) {
                    starttime = tv_wp_manul_start.getText().toString().trim();
                    enttime = tv_wp_manul_end.getText().toString().trim();
                    etsc = et_wp_manul_sc.getText().toString().trim();
                    etzq = et_wp_manul_zq.getText().toString().trim();
                    //进行判断是否有选中的阀门
                    boolean isSlectZq = false;
                    int sizess = wp_mchoice_fmAdapter.getIsBoolean().size();
                    for (int i = 0; i < sizess; i++) {
                        if (wp_mchoice_fmAdapter.getIsBoolean().get(i)) {
                            isSlectZq = true;
                        }
                    }
                    if (!isSlectZq) {
                        ToastUtil.showInfo(getActivity(), "请选择风机");
                        return;
                    }
                    if (DeviceUtil.isInputNull(getActivity(), starttime, enttime, etsc, etzq)) {
                        if (arrayList.size() == listFa.size()) {
                            ToastUtil.showInfo(getActivity(), "您的风机已选完");
                            return;
                        }
                        if (iszqplantId) {
                            ToastUtil.showInfo(getActivity(), "您已添加此组计划");
                            return;
                        }
                        int size = wp_mchoice_fmAdapter.getIsBoolean().size();
                        for (int i = 0; i < size; i++) {
                            if (wp_mchoice_fmAdapter.getIsBoolean().get(i)) {
                                FameZqBean fameZqBean = new FameZqBean();
                                fameZqBean.setSystemId(listFa.get(i).getSYSTEMID());
                                fameZqBean.setGROUPID(mplantId);
                                fameZqBean.setDevName(listFa.get(i).getNAME());
                                fameZqBean.setCTRLID(listFa.get(i).getCTRLID());
                                fameZqBean.setEQPID(listFa.get(i).getDEVID());
                                fameZqBean.setStarttime(tv_wp_manul_start.getText().toString().trim());
                                fameZqBean.setEndtime(tv_wp_manul_end.getText().toString().trim());
                                fameZqBean.setSc(Integer.valueOf(et_wp_manul_sc.getText().toString().trim()));
                                fameZqBean.setZq(Integer.valueOf(et_wp_manul_zq.getText().toString().trim()));
                                arrayList.add(fameZqBean);
                                entbtn.set(i, true);
                            }
                        }
                        if (arrayList.size() != 0) {
                            mplantId++;
                            iszqplantId = true;
                            tv_wpzq_qd.setSelected(true);
                            endprior = com.xianbeiying.app.ckgl.util.DataUtil.getTime(tv_wp_manul_end.getText().toString().trim(), "yyyy-MM-dd HH:mm");
                            tv_wpzq_qd.setText("计划(" + mplantId + ")");
                            eZqBean = DeviceUtil.getArrayZqBean(arrayList);
                            equipMentZqAdapter = new EquipmentZqAdapter(getActivity(), eZqBean);
                            equipMentZqAdapter.setHandler(handler);
                            wp_manul_list.setAdapter(equipMentZqAdapter);
                            ToastUtil.showInfo(getActivity(), "设置成功");
                            et_wp_manul_sc.setText("");
                            et_wp_manul_zq.setText("");
                            tv_wp_manul_start.setText("");
                            tv_wp_manul_end.setText("");
                            wp_manulgrid.setAdapter(null);
                        }
                    }
                } else {
                    ToastUtil.showInfo(getActivity(), "请选择风机");
                }
                break;
            //自动参与计划
            case R.id.tv_wpzd_qd:
                if (wp_achoice_Adapter != null) {
                    rd_wp_auto.setVisibility(View.VISIBLE);
                    String sdx = et_wpauto_sd.getText().toString().trim();
                    String sds = et_wpauto_wd.getText().toString().trim();
                    etsc = et_wpauto_sc.getText().toString().trim();
                    //进行判断是否有选中的阀门
                    boolean isSlectZq = false;
                    int sizess = wp_achoice_Adapter.getIsBoolean().size();
                    for (int i = 0; i < sizess; i++) {
                        if (wp_achoice_Adapter.getIsBoolean().get(i)) {
                            isSlectZq = true;
                        }
                    }
                    if (!isSlectZq) {
                        ToastUtil.showInfo(getActivity(), "请选择风机");
                        return;
                    }
                    if (DeviceUtil.isInputContent(getActivity(), sdx, sds, etsc,"风机")) {
                        if (autoarrayList.size() == listFa.size()) {
                            ToastUtil.showInfo(getActivity(), "您的风机已选完");
                            return;
                        }
                        if (iszdplantId) {
                            ToastUtil.showInfo(getActivity(), "您已添加此组计划");
                            return;
                        }
                        int size = wp_achoice_Adapter.getIsBoolean().size();
                        for (int i = 0; i < size; i++) {
                            if (wp_achoice_Adapter.getIsBoolean().get(i)) {
                                FameZqBean fameZqBean = new FameZqBean();
                                fameZqBean.setSystemId(listFa.get(i).getSYSTEMID());
                                fameZqBean.setGROUPID(aplantId);
                                fameZqBean.setDevName(listFa.get(i).getNAME());
                                fameZqBean.setCTRLID(listFa.get(i).getCTRLID());
                                fameZqBean.setEQPID(listFa.get(i).getDEVID());
                                fameZqBean.setMinSd(Integer.valueOf(sdx));
                                fameZqBean.setMaxSd(Integer.valueOf(sds));
                                fameZqBean.setSc(Integer.valueOf(etsc));
                                autoarrayList.add(fameZqBean);
                                zdtbtn.set(i, true);
                            }
                        }
                        if (autoarrayList.size() != 0) {
                            aplantId++;
                            iszdplantId = true;
                            tv_wpzd_qd.setSelected(true);
                            tv_wpzd_qd.setText("计划(" + aplantId + ")");
                            eZdBean = DeviceUtil.getArrayZdBean(autoarrayList);
                            equipMentZdAdapter = new EquipmentZdAdapter(getActivity(), eZdBean, "风机");
                            wp_auto_list.setAdapter(equipMentZdAdapter);
                            ToastUtil.showInfo(getActivity(), "设置成功");
                            et_wpauto_sc.setText("");
                            et_wpauto_sd.setText("");
                            et_wpauto_wd.setText("");
                            wp_autogrid.setAdapter(null);
                        }
                    }
                } else {
                    ToastUtil.showInfo(getActivity(), "请选择风机");
                }
                break;
            //年//月//日
            case R.id.et_year:
            case R.id.et_month:
            case R.id.et_day:
                final Calendar calendar = Calendar.getInstance();
                final DatePickerDialog datePickerDialog = DatePickerDialog.newInstance(this, calendar.get(Calendar.YEAR),
                        calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), true);
                datePickerDialog.setYearRange(1985, 2028);
                datePickerDialog.setCloseOnSingleTapDay(true);
                datePickerDialog.show(getActivity().getSupportFragmentManager(), "");
                break;
            //时//分
            case R.id.et_hh:
            case R.id.et_mm:
                selectTime=new CenterPopWindow(getActivity(),R.layout.pop_window_numbertime);
                mPickerViewH =selectTime.getView(R.id.picker_hour);
                mPickerViewM =selectTime.getView(R.id.picker_minute);
                initTime();
                selectTime.setTextOnClickListener(R.id.done,this);
                selectTime.setTextOnClickListener(R.id.ly_pop_time,this);
                break;
            //时间的确认
            case R.id.ly_pop_time:
                selectTime.dismiss();
                break;
            case R.id.done:
                et_hh.setText(mPickerViewH.getContentByCurrValue());
                et_mm.setText(mPickerViewM.getContentByCurrValue());
                selectTime.dismiss();
                break;
            //手动模式的打开
            case R.id.wp_open:
                if (vaManulList != null && vaManulList.size() != 0) {
                    sFmTypeBean = JsonBean.setSFmTypeData(wp_mchoice_fmAdapter, listFa, "打开", mmselectId);
                    setModel.SETFENJI(sFmTypeBean, true);
                } else {
                    ToastUtil.showInfo(getActivity(), "请选择风机");
                    return;
                }
                break;
            //手动模式的关闭
            case R.id.wp_close:
                if (vaManulList != null && vaManulList.size() != 0) {
                    sFmTypeBean = JsonBean.setSFmTypeData(wp_mchoice_fmAdapter, listFa, "关闭", mmselectId);
                    setModel.SETFENJI(sFmTypeBean, true);
                } else {
                    ToastUtil.showInfo(getActivity(), "请选择风机");
                    return;
                }
                break;
            //周期模式的启用
            case R.id.wp_zqopen:
                if (eZqBean != null && eZqBean.size() != 0) {
//                if(wp_zqclose.isChecked()){
//                    ToastUtil.showInfo(getActivity(),"您还未下停用计划");
//                    return;
//                }
                    if (isZqPlant) {
                        //有周期计划,1.当周期行计划是运行时，先停止,后删除,然后下发,再启动 2.当周期行计划是停止时,先删除,后下发,再启动
                        //当状态为1时为计划运行状态,当状态为3时为计划停止状态,当状态为-1时为计划未知状态
                        if (queZQBean.getV().getPLANS().get(0).getSTATUS() == -1) {
                            isDeleteZqPlant = true;
                            isDownZqPlant = true;
                            if (EquipmentZqAdapter.isStartZq) {
                                if (EquipmentZqAdapter.isChange) {
                                    setModel.STOP_CYCLEPLANS("STOP_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                                } else {
                                    //启动计划
                                    setModel.START_CYCLEPLANS("START_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                                }
                            } else {
                                ToastUtil.showInfo(getActivity(), "请确认分组完成");
                                wp_zqopen.setChecked(false);
                            }
                        } else if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 1) {
//                            isDeleteZqPlant = true;
//                            isDownZqPlant = true;
//                            setModel.STOP_CYCLEPLANS("STOP_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                        } else if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                            //直接删除
                            isDownZqPlant = true;
                            if (EquipmentZqAdapter.isStartZq) {

                                if (EquipmentZqAdapter.isChange) {
                                    deleteModel.DeleteQUERY_CYCLEPLANS("DELETE_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                                } else {
                                    //启动计划
                                    setModel.START_CYCLEPLANS("START_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                                }

                            } else {
                                ToastUtil.showInfo(getActivity(), "请确认分组完成");
                                wp_zqopen.setChecked(false);
                            }
                        }
                    } else {//无周期计划
                        isDownZqPlant = false;
                        if (EquipmentZqAdapter.isStartZq) {
                            setModel.SET_CYCLEPLANSS("SET_CYCLEPLANS", 2, EQP.EQP_TYPE_FAN, eZqBean, true);
                        } else {
                            ToastUtil.showInfo(getActivity(), "请确认分组完成");
                            wp_zqopen.setChecked(false);
                        }

                    }
                } else {
                    wp_zqopen.setChecked(false);
                    wp_zqclose.setChecked(true);
                    ToastUtil.showInfo(getActivity(), "请参与计划");
                    return;
                }
                break;
            //周期模式的停用
            case R.id.wp_zqclose:
//                if(!wp_zqopen.isChecked()){
//                    ToastUtil.showInfo(getActivity(),"您还未下发计划");
//                    return;
//                }
                if (isZqPlant) {
                    if (devicesBean != null)
                        if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 3) {

                        } else {
                            isDeleteZqPlant = false;
                            setModel.STOP_CYCLEPLANS("STOP_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                        }
                }
                break;
            //自动模式的启用
            case R.id.wp_start:
                if (eZdBean != null && eZdBean.size() != 0) {
//                if(wp_stop.isChecked()){
//                    ToastUtil.showInfo(getActivity(),"您还未停用计划");
//                    return;
//                }
                    if (isZdPlant) {
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == -1) {
                            isDeleteZdPlant = true;
                            isDownZdPlant = true;
                            if (EquipmentZdAdapter.isStartZd) {
                                if (EquipmentZdAdapter.isChange) {
                                    setModel.STOP_TRIGGERPLANS("STOP_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                                } else {
                                    //启动计划
                                    setModel.START_TRIGGERPLANS("START_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                                }
                            } else {
                                ToastUtil.showInfo(getActivity(), "请确认分组完成");
                                wp_start.setChecked(false);
                            }
                        } else if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 1) {
//                            isDeleteZdPlant = true;
//                            isDownZdPlant = true;
//                            setModel.STOP_TRIGGERPLANS("STOP_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                        } else if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                            //直接删除
                            isDownZdPlant = true;
                            if (EquipmentZdAdapter.isStartZd) {
                                if (EquipmentZdAdapter.isChange) {
                                    deleteModel.DeleteQUERY_TRIGGERPLANS("DELETE_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                                } else {
                                    //启动计划
                                    setModel.START_TRIGGERPLANS("START_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                                }
                            } else {
                                ToastUtil.showInfo(getActivity(), "请确认分组完成");
                                wp_start.setChecked(false);
                            }
                        }
                    } else {
                        isDownZdPlant = false;
                        if (EquipmentZdAdapter.isStartZd) {
                            setModel.SET_TRIGGERPLANSS("SET_TRIGGERPLANS", 3, EQP.EQP_TYPE_FAN, eZdBean, true);
                        } else {
                            ToastUtil.showInfo(getActivity(), "请确认分组完成");
                            wp_start.setChecked(false);
                        }
                    }
                } else {
                    wp_start.setChecked(false);
                    wp_stop.setChecked(true);
                    ToastUtil.showInfo(getActivity(), "请参与计划");
                    return;
                }
                break;
            //自动模式的停用
            case R.id.wp_stop:
//                if(!wp_start.isChecked()){
//                    ToastUtil.showInfo(getActivity(),"您还未下发计划");
//                    return;
//                }
                if (isZdPlant) {
                    if (devicesBean != null)
                        isDeleteZdPlant = false;
                    if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                    } else {
                        setModel.STOP_TRIGGERPLANS("STOP_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                    }
                }
                break;
            //删除周期计划
            case R.id.tv_wpzq_delete:
                if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 1) {
                    ToastUtil.showInfo(getActivity(),"该计划正在运行中,请先停止计划,再进行删除");
                    return;
                }
                zQdeletepop = new CenterPopWindow(getActivity(), R.layout.pop_window_delete);
                zQdeletepop.setTextOnClickListener(R.id.tv_delete, this);
                zQdeletepop.setTextOnClickListener(R.id.tv_cancel, this);
                zQdeletepop.setTextOnClickListener(R.id.ly_exit, this);
                break;
            //删除自动计划
            case R.id.tv_wpzd_delete:
                if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 1) {
                    ToastUtil.showInfo(getActivity(),"该计划正在运行中,请先停止计划,再进行删除");
                    return;
                }
                zDdeletepop = new CenterPopWindow(getActivity(), R.layout.pop_window_delete);
                zDdeletepop.setTextOnClickListener(R.id.tv_delete, this);
                zDdeletepop.setTextOnClickListener(R.id.tv_cancel, this);
                zDdeletepop.setTextOnClickListener(R.id.ly_exit, this);
                break;
            //泡泡窗口的取消
            case R.id.tv_cancel:
            case R.id.ly_exit:
                if (zQdeletepop != null && zQdeletepop.isShowing())
                    zQdeletepop.dismiss();
                if (zDdeletepop != null && zDdeletepop.isShowing())
                    zDdeletepop.dismiss();
                break;
            //自动泡泡窗口的删除按钮
            case R.id.tv_delete:
                //自动
                if (zDdeletepop != null && zDdeletepop.isShowing()) {
                    if (isZdPlant) {
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == -1) {
                            isDeleteZdPlant = true;
                            isDownZdPlant = false;
                            setModel.STOP_TRIGGERPLANS("STOP_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                        }
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 1) {//正在运行
                            isDownZdPlant = false;
                            isDeleteZdPlant = true;
                            setModel.STOP_TRIGGERPLANS("STOP_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                        }
                        if (queZDBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                            isDownZdPlant = false;
                            deleteModel.DeleteQUERY_TRIGGERPLANS("DELETE_TRIGGERPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 3, true);
                        }
                    }
                }
                //周期
                if (zQdeletepop != null && zQdeletepop.isShowing()) {
                    if (queZQBean.getV().getPLANS().get(0).getSTATUS() == -1) {
                        isDeleteZqPlant = true;
                        isDownZqPlant = false;
                        setModel.STOP_CYCLEPLANS("STOP_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                    }
                    if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 1) {
                        isDeleteZqPlant = true;
                        isDownZqPlant = false;
                        setModel.STOP_CYCLEPLANS("STOP_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                    }
                    if (queZQBean.getV().getPLANS().get(0).getSTATUS() == 3) {
                        //直接删除
                        isDownZqPlant = false;
                        deleteModel.DeleteQUERY_CYCLEPLANS("DELETE_CYCLEPLANS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), 2, true);
                    }
                }

                break;
        }
    }

    //时间的设置
    private void initTime(){
        GregorianCalendar calendar = (GregorianCalendar) GregorianCalendar.getInstance();
        int h = calendar.get(Calendar.HOUR_OF_DAY);
        int m = calendar.get(Calendar.MINUTE);
        h = h % 24;
        setData(mPickerViewH, 0, 23, h);
        setData(mPickerViewM, 0, 59, m);
    }

    private void setData(NumberPickerView picker, int minValue, int maxValue, int value){
        picker.setMinValue(minValue);
        picker.setMaxValue(maxValue);
        picker.setValue(value);
    }

    //周期设置
    private void setZq() {
        showDefault();
        selectModelId = 1;
        mplantId = 0;
        isZqplant=true;
        listFa = DataUtil.getSeBei(faMenBean, EQP.EQP_TYPE_FAN);
        fmType = DataUtil.getFmOcc(listFa);
        tv_wpzq_delete.setVisibility(View.GONE);
        ly_cc_mmanul.setVisibility(View.VISIBLE);
        wp_manul_list.setVisibility(View.VISIBLE);
        tv_wpzq_qd.setSelected(false);
        tv_wpzq_qd.setEnabled(true);
        tv_wpzq_qd.setText("参与计划");
        ly_wp_manul.setVisibility(View.VISIBLE);
        tv_wpzq_qd.setVisibility(View.VISIBLE);
        ly_wp_zq.setVisibility(View.VISIBLE);
        rd_wp_zqmanul.setVisibility(View.VISIBLE);
        ly_cy_plant.setVisibility(View.VISIBLE);
        iv_wp_zq.setSelected(true);
        wp_zqclose.setChecked(true);
    }

    //自动设置
    private void setZd() {
        showDefault();
        selectModelId = 2;
        aplantId = 0;
        isZdplant=true;
        listFa = DataUtil.getSeBei(faMenBean, EQP.EQP_TYPE_FAN);
        fmType = DataUtil.getFmOcc(listFa);
        tv_wpzd_delete.setVisibility(View.GONE);
        wp_auto_list.setVisibility(View.VISIBLE);
        tv_wpzd_qd.setVisibility(View.VISIBLE);
        ly_wp_auto.setVisibility(View.VISIBLE);
        rd_wp_auto.setVisibility(View.VISIBLE);
        ly_zdplant.setVisibility(View.VISIBLE);
        ly_auto_middle.setVisibility(View.VISIBLE);
        iv_wp_zd.setSelected(true);
        tv_wpzd_qd.setText("参与计划");
        tv_wpzd_qd.setSelected(false);
        tv_wpzd_qd.setEnabled(true);
        wp_stop.setChecked(true);
    }

    /**
     * 自动阀门窗口的显示
     */
    private void showZdpopWindow() {
        aautoPop = new LayoutPopWindow(getActivity(), R.layout.pop_window_choicewp, tv_sb_wpauto);
        NoScrollListView alistView = aautoPop.getView(R.id.choice_wp_lists);
        int widths = AppManager.getInstance().getWindowSizeEntity().getWidth() / 2;
        ScrollView ly_choice_wps = aautoPop.getView(R.id.ly_choice_wp);
        com.xianbeiying.app.ckgl.util.DataUtil.setHeight(ly_choice_wps, widths);
        if(listFa!=null&&listFa.size()!=0){
        wp_achoice_Adapter = new PopWindowChoiceWpAdapter(getActivity(), listFa, "号风机", fmType);
        wp_achoice_Adapter.setIsBoolean(StringUtil.getList(listFa.size()));
        alistView.setAdapter(wp_achoice_Adapter);}
        aautoPop.setViewOnClickListener(R.id.tv_qchoicewp, this);
        et_wpauto_sc.setText("");
        et_wpauto_sd.setText("");
        et_wpauto_wd.setText("");
        alistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (fmType[position].equals("运行")) {
                    ToastUtil.showInfo(getActivity(), "此风机正在运行状态,不可选");
                    return;
                }
                if (DeviceUtil.isButtonSelect(getActivity(), zdtbtn, position)) {
                    return;
                }
                DataUtil.setZqBooleanArray(wp_achoice_Adapter, position);
                wp_achoice_Adapter.notifyDataSetChanged();


            }
        });
    }

    /**
     * 手动或者周期的阀门窗口显示
     */
    private void showSorZpopWindow() {
        mmanulPop = new LayoutPopWindow(getActivity(), R.layout.pop_window_choicewp, tv_sb_wpmanul);
        NoScrollListView mlistView = mmanulPop.getView(R.id.choice_wp_lists);
        ScrollView ly_choice_wp = mmanulPop.getView(R.id.ly_choice_wp);
        //窗口宽度设置
        int width = AppManager.getInstance().getWindowSizeEntity().getWidth() / 2;
        com.xianbeiying.app.ckgl.util.DataUtil.setHeight(ly_choice_wp, width);
        if(listFa!=null&&listFa.size()!=0){
        wp_mchoice_fmAdapter = new PopWindowChoiceWpAdapter(getActivity(), listFa, "号风机", fmType);
        wp_mchoice_fmAdapter.setIsBoolean(StringUtil.getList(listFa.size()));
        mlistView.setAdapter(wp_mchoice_fmAdapter);}
        mmanulPop.setViewOnClickListener(R.id.tv_qchoicewp, this);
        if (selectModelId == 0) {
            RabutUtil.setRabutChoice(fmType, wp_open, wp_close, mmselectId);
        }
        if (selectModelId == 1) {
            et_wp_manul_sc.setText("");
            et_wp_manul_zq.setText("");
            tv_wp_manul_start.setText("");
            tv_wp_manul_end.setText("");
        }
        mlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (selectModelId == 0) {
                    mmselectId = position;
                    DataUtil.setBooleanArray(wp_mchoice_fmAdapter, position);
                    RabutUtil.setRabutChoice(fmType, wp_open, wp_close, position);
                }
                if (selectModelId == 1) {
                    if (fmType[position].equals("运行")) {
                        ToastUtil.showInfo(getActivity(), "此风机正在运行状态,不可选");
                        return;
                    }
                    if (DeviceUtil.isButtonSelect(getActivity(), entbtn, position)) {
                        return;
                    }
                    DataUtil.setZqBooleanArray(wp_mchoice_fmAdapter, position);
                }
                wp_mchoice_fmAdapter.notifyDataSetChanged();
            }
        });
    }

    /**
     * 设置灌溉模式的默认状态
     **/
    private void showDefault() {
        //获取所有的设置信息
//        getModel.QUWEYDEVSDetauls("GET_ALLDEVICES_STATUS", devicesBean.getGREENHOUSE().get(faId).getGreenhouseId(), true);
        ly_wp_manul.setVisibility(View.GONE);
        ly_wp_auto.setVisibility(View.GONE);
        ly_wp_zq.setVisibility(View.GONE);
        rd_wp_manul.setVisibility(View.GONE);
        rd_wp_zqmanul.setVisibility(View.GONE);
        rd_wp_auto.setVisibility(View.GONE);
        iv_wp_sd.setSelected(false);
        iv_wp_zq.setSelected(false);
        iv_wp_zd.setSelected(false);
        wp_manul_list.setVisibility(View.GONE);
        wp_auto_list.setVisibility(View.GONE);
        ly_choice_wp_manul.setVisibility(View.GONE);
        ly_choice_wp_auto.setVisibility(View.GONE);
        tv_wpzq_qd.setVisibility(View.GONE);
        tv_wpzd_qd.setVisibility(View.GONE);
        if (fmType != null) entbtn = StringUtil.getList(fmType.length);
        if (fmType != null) zdtbtn = StringUtil.getList(fmType.length);
        if (eZqBean != null) eZqBean.clear();
        if (eZdBean != null) eZdBean.clear();
        if (arrayList != null) arrayList.clear();
        if (autoarrayList != null) autoarrayList.clear();
        et_wp_manul_sc.setText("");
        et_wp_manul_zq.setText("");
        tv_wp_manul_start.setText("");
        tv_wp_manul_end.setText("");
        et_wpauto_sc.setText("");
        et_wpauto_sd.setText("");
        et_wpauto_wd.setText("");
        ly_zdplant.setVisibility(View.GONE);
        ly_auto_middle.setVisibility(View.GONE);
        rd_wp_auto.setVisibility(View.GONE);
        ly_wp_zq.setVisibility(View.GONE);
        rd_wp_zqmanul.setVisibility(View.GONE);
    }

    //泡泡窗口的时间：年，月，日，时，分
    private TextView et_year, et_month, et_day, et_hh, et_mm;

    /**
     * 开始时间窗口
     */
    private void showStartTimePopWindow() {
        manulstarttime = new CenterPopWindow(getActivity(), R.layout.pop_choice_time);
        manulstarttime.setText(R.id.pop_time_title, "开始时间");
        et_year = manulstarttime.getView(R.id.et_year);
        et_month = manulstarttime.getView(R.id.et_month);
        et_day = manulstarttime.getView(R.id.et_day);
        et_hh = manulstarttime.getView(R.id.et_hh);
        et_mm = manulstarttime.getView(R.id.et_mm);
        manulstarttime.setTextOnClickListener(R.id.et_year, this);
        manulstarttime.setTextOnClickListener(R.id.et_month, this);
        manulstarttime.setTextOnClickListener(R.id.et_day, this);
        manulstarttime.setTextOnClickListener(R.id.et_hh, this);
        manulstarttime.setTextOnClickListener(R.id.et_mm, this);
        //关闭窗口
        manulstarttime.setTextOnClickListener(R.id.ly_pop_chocice_time, this);
        //确定
        manulstarttime.setTextOnClickListener(R.id.tv_pop_qtime, this);
        if (itemSelectId == 0) {
            tv_wp_manul_end.setText("");
            et_wp_manul_sc.setText("");
        }
    }

    /**
     * 结束时间窗口
     */
    private void showEndTimePop() {
        manulendtime = new CenterPopWindow(getActivity(), R.layout.pop_choice_time);
        manulendtime.setText(R.id.pop_time_title, "结束时间");
        et_year = manulendtime.getView(R.id.et_year);
        et_month = manulendtime.getView(R.id.et_month);
        et_day = manulendtime.getView(R.id.et_day);
        et_hh = manulendtime.getView(R.id.et_hh);
        et_mm = manulendtime.getView(R.id.et_mm);
        manulendtime.setTextOnClickListener(R.id.et_year, this);
        manulendtime.setTextOnClickListener(R.id.et_month, this);
        manulendtime.setTextOnClickListener(R.id.et_day, this);
        manulendtime.setTextOnClickListener(R.id.et_hh, this);
        manulendtime.setTextOnClickListener(R.id.et_mm, this);
        //关闭窗口
        manulendtime.setTextOnClickListener(R.id.ly_pop_chocice_time, this);
        //确定
        manulendtime.setTextOnClickListener(R.id.tv_pop_qtime, this);
    }

    /**
     * 时间选择年月日
     */
    @Override
    public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
        et_year.setText(year + "");
        et_month.setText((month + 1) + "");
        et_day.setText(day + "");
    }


}
